<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@include file="../include/jspheader.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>发布机票</title>
<link href="/css/ui.core.css" rel="stylesheet" type="text/css">
<link href="/css/ui.flight.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=ctx%>/js/jquery-1.4.4.min.js"></script>
<script language="javascript" type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">.lb_content {display : none ; position : absolute ; z-index:10000 ; left:0 ;}.lb_overlay {display : none ; position : absolute ; z-index:10000 ; background-color : #000 ; left : 0px ; top : 0px ; opacity : 0.2 ; filter: Alpha(opacity=20) ;}</style>
    <script type="text/javascript">
        /*用于新增的行*/
        var newTrFlag = "<td class='c1'><input type='text' onfocus='WdatePicker({skin:\"whyGreen\",dateFmt:\"yyyy-MM-dd\"})' class='Wdate'/></td><td class='c2'><input type='text'/></td><td class='c3'><input type='text'/></td><td class='c4'><input type='text'/></td><td class='c5'><input type='text'/></td><td class='c5'><a href='#' onclick='deleteRow(this)'>删除</a></td>";

        function addRow() {
            $('#storage').append("<tr id='tcXI3' class='ico'>" + newTrFlag + "</tr>");
            //$('#storage').find("tr:last").find('#wordText')[0].focus();
        }
        function deleteRow(obj) {
            $(obj).parent().parent().remove();
        }

        function saveFlight(){
            var storageArrays = [];
            var storageList = $('#storage').children();
            for(var i = 1; i < storageList.length; i++){
                var storage = {};
                storage.boarding_date = $(storageList[i]).find("td:eq(0)").find("input:first").val();
                storage.classType = $(storageList[i]).find("td:eq(1)").find("input:first").val();
                storage.discount = $(storageList[i]).find("td:eq(2)").find("input:first").val();
                storage.spec_discount = $(storageList[i]).find("td:eq(3)").find("input:first").val();
                storage.current_count = $(storageList[i]).find("td:eq(4)").find("input:first").val();
                storage.index = i;
                if(storage.boarding_date != "" && storage.classType !="" && storage.discount != "" && storage.spec_discount != "" && storage.current_count !=""){
                    storageArrays.push(storage);
                }else{
                    alert("请填写完整的价格信息!");
                    return false;
                }
            }
            $('#storageJson').val(JSON.stringify(storageArrays));
            $('#flightForm').submit();
        }
    </script>
</head>

<body>
<div class="container" id="container">
  <form action="addFlightTicket.action" method="post" id="flightForm">
      <input type="hidden" id="storageJson" name="storageJson" value="" />
    <div id="bookingInfo" class="bookingInfo">
      <div id="buInfoXI3" class="">
        <div class="t_block2 bookingfinfo">
          <div class="hd">
            <div class="wrap">添加航班信息</div>
          </div>
          <div class="ct">
              <table cellpadding="0" cellspacing="0" width="100%">
                  <tbody>
                  <tr>
                      <th class="c2">航空公司</th>
                      <th class="c2">航班号</th>
                      <th class="c2">标准价格（元）</th>
                      <th class="c2">机场建设费（元）</th>
                      <th class="c2">燃油附加费（元）</th>
                      <th class="c2">里程（公里）</th>
                      <th class="c6"></th>
                      <th class="c6"></th>
                  </tr>
                  <tr>
                      <td class="c1">
                          <select name="flight.flight_company" style="border: 1px solid #7f9db9; height: 20px; line-height: 20px; width: 120px; margin: 0; padding: 0;">>
                              <option value="西藏航空">西藏航空</option>
                              <option value="中国航空">中国航空</option>
                          </select>
                      </td>
                      <td ><input type="text" name="flight.flight_num" value="<s:property value="flight.flight_num"/>" /></td>
                      <td ><input type="text" name="flight.standard_fee" value="<s:property value="flight.standard_fee"/>" /></td>
                      <td ><input type="text" name="flight.build_fee" value="<s:property value="flight.build_fee"/>" /></td>
                      <td ><input type="text" name="flight.fuel_fee" value="<s:property value="flight.fuel_fee"/>" /></td>
                      <td class="c2"><input type="text" name="flight.milage" value="<s:property value="flight.milage"/>" /></td>
                      <td ></td>
                      <td ></td>
                  </tr>
                  <tr>
                      <th class="c2">出发城市</th>
                      <th class="c2">出发机场</th>
                      <th class="c2">出发航站楼</th>
                      <th class="c2">出发时间</th>
                      <th class="c2">到达城市</th>
                      <th class="c2">到达机场</th>
                      <th class="c2">到达航站楼</th>
                      <th class="c2">到达时间</th>
                  </tr>
                  <tr>
                      <td class="c2">
                          <select name="flight.start_city" id="start_city" style="border: 1px solid #7f9db9; height: 20px; line-height: 20px; width: 120px; margin: 0; padding: 0;" >
								</select>
								<script type="text/javascript">
									$.getJSON('resources/cities_2.json',function(json) {
										$.each(json, function(index) {
											$("#start_city").append("<option value=\""+json[index]+"\">"+json[index]+"</option>");
										});
										$("#start_city").val("B北京");
									});
								</script>
                      </td>
                      <td class="c1"><input type="text" name="flight.start_airport" value="<s:property value="flight.start_airport"/>"/></td>
                      <td class="c3"><input type="text" name="flight.start_terminal" value="<s:property value="flight.start_terminal"/>"/></td>
                      <td class="c4"><input type="text" name="flight.start_time" id="d242" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" class="Wdate" value="<s:property value="flight.start_time"/>"/></td>
                      <td class="c2">
                          <select name="flight.end_city" id="end_city" style="border: 1px solid #7f9db9; height: 20px; line-height: 20px; width: 120px; margin: 0; padding: 0;">
								</select>
								<script type="text/javascript">
									$.getJSON('resources/cities_2.json',function(json) {
										$.each(json, function(index) {
											$("#end_city").append("<option value=\""+json[index]+"\">"+json[index]+"</option>");
										});
										$("#end_city").val("S上海");
									});
								</script>
                      </td>
                      <td class="c5"><input type="text" name="flight.end_airport" value="<s:property value="flight.end_airport"/>"/></td>
                      <td class="c7"><input type="text" name="flight.end_terminal" value="<s:property value="flight.end_terminal"/>"/></td>
                      <td class="c8"><input type="text" name="flight.end_time" id="d243" value="<s:property value="flight.start_time"/>" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" class="Wdate"/></td>
                  </tr>
                  </tbody>
              </table>
          </div>
        </div>
        <div class="t_block2 pinfo">
          <div class="hd">
            <div class="wrap">添加价格信息</div>
          </div>
          <div class="ct">
            <table cellpadding="0" cellspacing="0" width="100%">
              <tbody id="storage">
                <tr>
                  <th class="c1">时间</th>
                  <th class="c2">舱位</th>
                  <th class="c3">折扣率</th>
                  <th class="c4">儿童\伤残军人折扣率</th>
                  <th class="c5">数量</th>
                  <th class="c5">操作</th>
                </tr>
                <s:iterator value="storageDOList">
                    <tr class="ico">
                        <td class="c1"><input type="text" value="<s:property value="boarding_date"/>" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/></td>
                        <td class="c2"><input type="text" value="<s:property value="class_type"/>"/></td>
                        <td class="c3"><input type="text" value="<s:property value="discount"/>"/></td>
                        <td class="c4"><input type="text" value="<s:property value="spec_discount"/>"/></td>
                        <td class="c5"><input type="text" value="<s:property value="current_count"/>"/></td>
                        <td class="c5"><a href="#" onclick="deleteRow(this)">删除</a></td>
                    </tr>
                </s:iterator>
                <tr id="tcXI3" class="ico">
                  <td class="c1"><input type="text" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/></td>
                  <td class="c2"><input type="text" value=""/></td>
                  <td class="c3"><input type="text" value=""/></td>
                  <td class="c4"><input type="text" value=""/></td>
                  <td class="c5"><input type="text" value=""/></td>
                  <td class="c5"><a href="#" onclick="deleteRow(this)">删除</a></td>
                </tr>
              </tbody>
            </table>
            </br>
            <a href="#" onclick="addRow()">+增加一行</a>
          </div>
        </div>
        <div class="allPrice" id="allPrice">
            <input type="button" onclick="saveFlight()" value="提交" />
        </div>
        <s:actionmessage cssStyle="color:#008000;" escape="false"/>
        <s:actionerror cssStyle="color:red;" escape="false"/>
      </div>
    </div>
  </form>
</div>
</body>
</html>